package com.lanou.managerLogin.category.web.servlet;

import com.lanou.managerLogin.category.service.CategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteCategoryServletTwo")
public class DeleteCategoryServletTwo extends HttpServlet {

    private CategoryService cs = new CategoryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String cid = req.getParameter("cid");
        String cname = req.getParameter("cname");
        System.out.println(cid + cname);
        if (cname == null || cname.length() == 0) {
            req.getRequestDispatcher("/adminjsps/admin/category/list.jsp").forward(req, resp);
        } else {
            cs.deleteCategory(cid);
            req.getRequestDispatcher("/adminjsps/admin/category/list.jsp").forward(req, resp);
        }
    }
}
